package com.ruoyi.youtian.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.youtian.domain.ScdwStatisticalFrequency;
import com.ruoyi.youtian.service.IScdwStatisticalFrequencyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 统计分析按区站频率设置Controller
 * 
 * @author bl
 * @date 2022-11-29
 */
@Controller
@RequestMapping("/youtian/frequency")
public class ScdwStatisticalFrequencyController extends BaseController
{
    private String prefix = "tongjiNew/frequency";

    @Autowired
    private IScdwStatisticalFrequencyService scdwStatisticalFrequencyService;

    @RequiresPermissions("system:frequency:view")
    @GetMapping()
    public String frequency()
    {
        return prefix + "/frequency";
    }

    /**
     * 查询统计分析按区站频率设置列表
     */
    @RequiresPermissions("system:frequency:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ScdwStatisticalFrequency scdwStatisticalFrequency)
    {
        startPage();
        List<ScdwStatisticalFrequency> list = scdwStatisticalFrequencyService.selectScdwStatisticalFrequencyList(scdwStatisticalFrequency);
        return getDataTable(list);
    }

    /**
     * 导出统计分析按区站频率设置列表
     */
    @RequiresPermissions("system:frequency:export")
    @Log(title = "统计分析按区站频率设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ScdwStatisticalFrequency scdwStatisticalFrequency)
    {
        List<ScdwStatisticalFrequency> list = scdwStatisticalFrequencyService.selectScdwStatisticalFrequencyList(scdwStatisticalFrequency);
        ExcelUtil<ScdwStatisticalFrequency> util = new ExcelUtil<ScdwStatisticalFrequency>(ScdwStatisticalFrequency.class);
        return util.exportExcel(list, "统计分析按区站频率设置数据");
    }

    /**
     * 新增统计分析按区站频率设置
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存统计分析按区站频率设置
     */
    @RequiresPermissions("system:frequency:add")
    @Log(title = "统计分析按区站频率设置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ScdwStatisticalFrequency scdwStatisticalFrequency)
    {
        return toAjax(scdwStatisticalFrequencyService.insertScdwStatisticalFrequency(scdwStatisticalFrequency));
    }

    /**
     * 修改统计分析按区站频率设置
     */
    @RequiresPermissions("system:frequency:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ScdwStatisticalFrequency scdwStatisticalFrequency = scdwStatisticalFrequencyService.selectScdwStatisticalFrequencyById(id);
        mmap.put("scdwStatisticalFrequency", scdwStatisticalFrequency);
        return prefix + "/edit";
    }

    /**
     * 修改保存统计分析按区站频率设置
     */
    @RequiresPermissions("system:frequency:edit")
    @Log(title = "统计分析按区站频率设置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ScdwStatisticalFrequency scdwStatisticalFrequency)
    {
        return toAjax(scdwStatisticalFrequencyService.updateScdwStatisticalFrequency(scdwStatisticalFrequency));
    }

    /**
     * 删除统计分析按区站频率设置
     */
    @RequiresPermissions("system:frequency:remove")
    @Log(title = "统计分析按区站频率设置", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(scdwStatisticalFrequencyService.deleteScdwStatisticalFrequencyByIds(ids));
    }
}
